package net.example.utils;

import com.oraycn.esframework.core.ClientType;

public  class Comment4OfflineFile {
    private static String Prefix = "OfflineFile:";

    public static String ParseUserID(String comment)
    {
        if (comment == null || !comment.startsWith(Comment4OfflineFile.Prefix))
        {
            return null;
        }
        String tmp = comment.substring(Comment4OfflineFile.Prefix.length());
        String[] ary = tmp.split("-");
        return ary[1];
    }

    public static Integer ParseClientType(String comment)
    {
        if (comment == null || !comment.startsWith(Comment4OfflineFile.Prefix))
        {
            return null;
        }

        String tmp = comment.substring(Comment4OfflineFile.Prefix.length());
        String[] ary = tmp.split("-");
        return Integer.parseInt(ary[0]);
    }

    public static String BuildComment(String accepterID ,ClientType senderType)
    {
        return Comment4OfflineFile.Prefix + senderType.getType() + "-" + accepterID;
    }
}
